import { Model } from 'mongoose';
import { IUserAction } from '../models/types';
import { BaseRepository } from './BaseRepository';

export class UserActionRepository extends BaseRepository<IUserAction> {
  private userActionModel: Model<IUserAction>;

  constructor(model: Model<IUserAction>) {
    super(model);
    this.userActionModel = model;
  }

  async findByUserId(userId: string, limit: number = 100): Promise<IUserAction[]> {
    return this.userActionModel.find({ userId })
      .sort({ createdAt: -1 })
      .limit(limit)
      .lean().exec();
  }
}
